package 领扣算法.AA中等题.旋转函数;

import java.util.Arrays;

public class Main {
    public int maxRotateFunction(int[] nums) {
        int sum= Arrays.stream(nums).sum();
        int max=0;
        for (int i = 0; i < nums.length; i++) {
            max+=i*nums[i];
        }
        int middle=max;
        for (int i = nums.length-1; i >=0; i--) {
            middle+=sum-nums[i]*nums.length;
            max=Math.max(middle,max);
        }
        return max;
    }
}
